package com.janus.multitypedemo.vb;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.janus.multitypedemo.R;
import com.janus.multitypedemo.bean.MainGame;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by janus on 2017/7/10.
 * BannerViewBinder
 */

public class MainGameViewBinder extends ItemViewBinder<MainGame, MainGameViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.layout_main_game, parent, false);
        return new ViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull MainGame item) {
        Glide.with(holder.imageView.getContext())
                .load(item.url)
                .into(holder.imageView);
        holder.tvTitle.setText(item.title);
        holder.tvTS.setText(item.type_size);
        holder.tvDesc.setText(item.desc);
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        ImageView imageView;
        TextView tvTitle, tvTS, tvDesc;

        public ViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.iv_maingame);
            tvTitle = (TextView) itemView.findViewById(R.id.tv_maingame_title);
            tvTS = (TextView) itemView.findViewById(R.id.tv_maingame_type_size);
            tvDesc = (TextView) itemView.findViewById(R.id.tv_maingame_desc);
        }

    }
}
